home *** CD-ROM | disk | FTP | other *** search
- DefInt A-Z
-
- ' Removes various menu items from the System menu of the specified Form.
- '
- Sub Remove_Items_From_Sysmenu (A_Form As Form)
-
- ' Obtain the handle to the forms System menu
- '
- HSysMenu = GetSystemMenu(A_Form.Hwnd, 0)
-
- ' Remove all but the MOVE and CLOSE options. The menu items
- ' must be removed starting with the last menu item.
- '
- R = RemoveMenu(HSysMenu, 8, MF_BYPOSITION) 'Switch to
- R = RemoveMenu(HSysMenu, 7, MF_BYPOSITION) 'Separator
- R = RemoveMenu(HSysMenu, 5, MF_BYPOSITION) 'Separator
-
- End Sub
-
- ' Since the Swap statement is not supported by Visual Basic, this
- ' routine is used to perform the task of swapping two integer values.
- '
- Sub Swap_Values (Param1, Param2)
-
- Temp = Param1
- Param1 = Param2
- Param2 = Temp
-
- End Sub
-
- ' Selecting a new drive from the list of a Drive controls drop
- ' down list does not generate an error if the drive is not ready,
- ' so when a new drive is selected, we determine if it is ready
- ' or not. This routine validates the selected drive and is use
- ' by both the SaveFileDlg's and Viewers's Drive control
- '
- Sub Validate_And_Change_Drives (A_Form As Form)
-
- On Error Resume Next
- Err = FALSE
-
- ' Invoking the Dir$() function with the selected drive will generate
- ' an error if the drive is not ready. We don't care about the return
- ' value, we just care if an error is generated or not.
- '
- Dummy$ = Dir$(Left$(A_Form.Drv_DriveList.Drive, 2))
-
- If Err Then
- '
- ' The drive was not ready, so prompt the user
- '
- Beep
- MsgBox Error$(Err), 16, "IconWorks - ERROR: " + Format$(Err)
-
- ' Reset the Drive Control back to its previously selected drive
- '
- A_Form.Drv_DriveList.Drive = Left$(A_Form.Dir_DirectoryList.Path, 2)
- Else
- ' The drive is ready, so change to that drive
- '
- ChDrive A_Form.Drv_DriveList.Drive
- A_Form.Dir_DirectoryList.Path = CurDir$
- End If
-
- On Error GoTo 0
-
- End Sub
-
- ' A Sub Main is used instead of a startup form to allow the user
- ' to startup either the Editor or Viewer as the main form. The
- ' Editor is the Default main form, however starting Spelling
- ' with a command line of "v" or "V" will start Spelling with
- ' the Viewer as the main form.
- '
- Sub Main ()
-
- ' Check video mode. If less than EGA, terminate Spelling
- '
- If Screen.Height < EGA_HEIGHT Then
- MsgBox "Spelling requires EGA or Better.", 16, "Spelling"
- End
- Else
- ' Since you cannot assign values like TAB, CR, and LF to string
- ' constants, the values of TAB and CRLF which are used frequently
- ' thoughout Spelling when displaying messages, these values are
- ' are assigned to the global string values of A_TAB and CRLF
- '
- A_TAB = Chr$(9)
- CRLF = Chr$(13) + Chr$(10)
-
- 'If Not Help_File_In_Path() Then
- ' Text = "ICONWRKS.HLP not found in your path." + CRLF + CRLF
- ' Text = Text + "Windows searches your PATH environment variable for help files, "
- ' Text = Text + "so you need to copy ICONWRKS.HLP to a directory included in your "
- ' Text = Text + "PATH if you wish to obtain help while running Spelling."
- ' MsgBox Text, 48, "Spelling help not available"
- 'End If
-
- ' Determine which form to use as main form, Editor) or the Viewer
- '
- If (Command$ = "") Or (UCase$(Left$(Command$, 1)) <> "V") Then
- '
- ' Editor is main form
- '
- MainForm = ICONWORKS_EDITOR
- AboutBox.Show
- Else
- ' Viewer is main form
- '
- MainForm = ICONWORKS_VIEWER
- AboutBox.Show
- End If
- End If
-
- End Sub
-
- ' Displays the selected help topic selected from either
- ' Editors;' or Viewer's help menu.
- '
- Sub Get_Help (HelpTopic As Integer)
-
- If HelpTopic = MID_USING_HELP Then
- '
- ' "Using Help" was selected so display the Standard Windows Help
- ' Topic for "Using Help".
- '
- R = WinHelp(Viewer.Hwnd, Dummy$, HELP_HELPONHELP, 0)
- Else
- ' A help topic other the "Using help" was selected.
- '
- R = WinHelp(Viewer.Hwnd, "ICONWRKS.HLP", HELP_CONTEXT, CLng(HelpTopic))
- End If
-
- End Sub
-
- ' This routine is used by the SaveFileDlg and the Viewer to update the
- ' filespec displayed in the FileName TextBox whenever the forms Directory
- ' ListBox control is Single Clicked. Since a Single click does not
- ' actually make a selection, this routine is called in response to a
- ' single click to display what would be the result if a double click
- ' is performed or if Enter is pressed.
- '
- Sub UpDate_FileSpec (A_Form As Form)
- Dim SelPath As String, CurPath As String, Slash As String
-
- CurPath = A_Form.Lbl_CurrentDirectory.Caption
- SelPath = A_Form.Dir_DirectoryList.List(A_Form.Dir_DirectoryList.ListIndex)
-
- Select Case A_Form.Dir_DirectoryList.ListIndex
-
- Case Is >= 0
- '
- ' A subdirectory from the Current directory was selected
- '
- I = Right$(CurPath, 1) <> "\"
- A_Form.Txt_FileName.Text = Right$(SelPath, Len(SelPath) - Len(CurPath) + I) + "\" + A_Form.File_FileList.Pattern
-
- Case Is = -1
- '
- ' The current directory was selected
- '
- A_Form.Txt_FileName.Text = A_Form.File_FileList.Pattern
-
- Case Is < -1
- '
- ' A parent directory of the Current directory was selected
- '
- SelPath = Right$(SelPath, Len(SelPath) - 2)
- If Len(SelPath) > 1 Then Slash = "\"
- A_Form.Txt_FileName.Text = SelPath + Slash + A_Form.File_FileList.Pattern
-
- End Select
-
- End Sub
-
- ' When a filespec is entered into either the Viewer's Filename
- ' TextBox or the SaveFileDlg's Filename TextBox, this routine is
- ' called to validate the FileSpec. The name and path, if one is
- ' given, is validated. If a valid FileSpec to an actual file is
- ' entered and the file does not exist, the return value depends
- ' on which Form called this routine, since a if called from the
- ' SaveFileDlg a "File Not Found" error is generated but that is
- ' OK since a file does not have to exist to write to it. However,
- ' if called from the Viewer, the same error will be generated but
- ' in this case the file must exists since the Viewer is wants to
- ' open the file for editing.
- '
- Function Validate_FileSpec (AForm As Form, MustExist)
- Dim Temp As String
-
- ' Enable error trapping
- '
- On Error GoTo ErrorInSpec
-
- Validate_FileSpec = FALSE
-
- ' Check for valid DOS Path and Filenames.
- '
- Temp = Dir$(AForm.Txt_FileName.Text)
-
- ' The following statement does alot. It the FileSpec contains
- ' a Path, the FileSpec will be parsed and the Path will be assign
- ' to the File ListBox's Path property. If the FileSpec contains
- ' Wild card characters, it will be assign to the File ListBox's
- ' pattern property. If the FileSpec contains a valid file name
- ' and the file exists, a Double Click event will automatically be
- ' generated for the File ListBox. If the File does not exist,
- ' a "File Not Found" error will be generated which we trap.
- '
- AForm.File_FileList.FileName = AForm.Txt_FileName.Text
-
- Exit_The_Function:
-
- ' Turn off error trapping and exit the function
- '
- On Error GoTo 0
- Exit Function
-
- ErrorInSpec:
- If (Err <> FILE_NOT_FOUND) Or ((Err = FILE_NOT_FOUND) And MustExist) Then
- '
- ' An error other than "File Not Found" occured, or the error
- ' "File Not Found" occured and this Function was invoked from
- ' the Viewer which requires the file to exist.
- '
- Beep
- MsgBox Error$(Err), 16, "IconWorks - ERROR: " + Format$(Err)
- Else
- ' The FileSpec entered contain no errors other than maybe
- ' "File Not Found".
- '
- If Err = FILE_NOT_FOUND Then
- ' A Valid filename was entered in the SaveFileDlg which did not exist
- ' so the File Control did not parse the FileSpec for us. Since the
- ' FileSpec could contain a path specification, force File control
- ' to parse the Filename string for us by changing last character to
- ' an asterisk "*" and assign the modified FileSpec to the File Controls
- ' FileName property. The asterisk "*" makes the Filename appear as a
- ' FileSpec rather than a Filename to the File ListBox and it will parse
- ' it for us whether there are any matching files or not. After it has
- ' been parsed, we change the "*" back to its previous value.
- '
- Temp = Right$(AForm.Txt_FileName.Text, 1)
- AForm.File_FileList.FileName = Left$(AForm.Txt_FileName.Text, Len(AForm.Txt_FileName.Text) - 1) + "*"
- AForm.Txt_FileName.Text = Left$(AForm.File_FileList.Pattern, Len(AForm.File_FileList.Pattern) - 1) + Temp
- End If
- Validate_FileSpec = TRUE
- End If
- Resume Exit_The_Function
-
- End Function
-
- Function Help_File_In_Path ()
- Dim Path As String, CurrentDir As String
-
- On Error Resume Next
-
- Path = Environ$("PATH")
- If Path <> "" Then
- If Right$(Path, 1) <> ";" Then Path = Path + ";"
- SemiColon = InStr(Path, ";")
- Do
- CurrentDir = Left$(Path, SemiColon - 1)
- If Right$(CurrentDir, 1) <> "\" Then CurrentDir = CurrentDir + "\"
- Found = Dir$(CurrentDir + "IconWrks.HLP") <> ""
- Path = Right$(Path, Len(Path) - SemiColon)
- SemiColon = InStr(Path, ";")
- Loop While ((SemiColon <> 0) And Not Found)
- End If
-
- Help_File_In_Path = Found
-
- On Error GoTo 0
-
- End Function
-
-